package com.qianfeng.biquge.mapper;

import com.qianfeng.biquge.pojo.Books;
import com.qianfeng.biquge.vo.BooksVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

public interface BookMapper {

    void addBook(Books books);

    @Select("select * from books where bookname like concat('%',#{bookname} ,'%') ")
    List<BooksVo> getAllBookByBookName(@Param("bookname") String bookname);

    @Select("select * from books where authorid=#{authorid} ")
    List<BooksVo> getAllBookByAuthorId(@Param("authorid") Long authorid);

    @Delete("delete from books where bookid=#{bookId} ")
    int deleteBook(@Param("bookId") Long bookId);

    @Select("select * from books where authorid=#{authorId} and bookid != #{bookId}")
    List<BooksVo> getBookByAuthoridByBookId(@Param("authorId") Long authorId, @Param("bookId") Long bookId);

    @Select("select * from books where categoryid=#{categoryId} ")
    List<BooksVo> getBookByCategoryIdIsRandom(@Param("categoryId") Long categoryId);

    @Select("select * from books where bookid=#{bookId}")
    Books getBookByBookId(@Param("bookId") Long bookId);

    @Select("select categoryid from books")
    List<Long>  getAllBookIsCategoryId();


}
